# Python 2.6.4
# Project Euler, Problem 56
# Copyright 2010 Talha Zaman

def digsum(n): return sum([int(c) for c in str(n)])
max = 0
for i in range(1,100):
    for j in range(1,100):
        ds = digsum(i**j)
        if max < ds: max = ds
print max
